import { RouteRecordRaw, createRouter, createWebHashHistory } from 'vue-router';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';
const routes: Array<any> = [
    {
        path: "/",
        redirect: "/login",
    },
    {
        path: "/login",
        name: "login",
        title: "登录",
        component: () => import("@/pages/login.vue"),
    },
    {
        path: '/index',
        name: 'layout',
        title: '首页',
        component: () => import('@/pages/layout.vue'),
        children: [
            {
                path: '',
                name: 'index',
                component: () => import('@/pages/index.vue')
            },
            {
                path: '/index/space',
                name: 'space',
                component: () => import('@/pages/space.vue')
            },
            {
                path: '/index/grow',
                name: 'grow',
                component: () => import('@/pages/grow.vue')
            },
            {
                path: '/index/see',
                name: 'seeindex',
                component: () => import('@/pages/see.vue')
            },
            {
                path: '/index/plane',
                name: 'plane',
                component: () => import('@/pages/plane.vue')
            },
        ]
    }
]

export const router = createRouter({
    history: createWebHashHistory(),
    routes,
});

router.beforeEach(async (to, from, next) => {
    NProgress.configure({ showSpinner: true });
    next()
})
router.afterEach(() => {
    NProgress.done()
})
export default router